// components/resume-item/index.js
const T = getApp().globalData.T
const config = getApp().globalData.config

Component({
  /**
   * 组件的属性列表
   */
  properties: {
    oldStatus: Number,
    interviewId: Number,
    positionId: Number,
    resumeId:Number,
    isHourly:Number
  },

  /**
   * 组件的初始数据
   */
  data: {
    status: 0,
  },
  observers: {
    'oldStatus': function (oldStatus) {
      this.setData({
        status: oldStatus
      })
    }
  },
  /**
   * 组件的方法列表
   */
  methods: {
    clickButton: function(e) {
      let type = e.currentTarget.dataset.type;
      if (type == 0) {
        let obj = { id: this.properties.positionId, resumeId: this.properties.resumeId, type: this.properties.isHourly, resumeDeliverId: this.properties.interviewId}
        wx.navigateTo({
          url: '../order/order?' + T.param(obj),
        })  
      } else {
        this.changeStatus(type);
      }

    },
    changeStatus: function(type) {
      T.req({
        loadTitle: '加载中...',
        url: config.api + 'interview/status?token=' + getApp().globalData.token + '&resumeDeliverId=' + this.properties.interviewId + '&operate=' + type,
        method: 'PUT',
        success: (res) => {
          T.toast({
            id: '#toast',
            text: '操作成功'
          })
          if (type == 4) {
            this.setData({
              status: 3
            })
          } else if (type == 3) {
            this.setData({
              status: 5
            })
          } else if (type == 2) {
            this.setData({
              status: 6
            })

          } else if (type == 1) {
            this.setData({
              status: 4
            })

          }
        }
      })
    }

  }
})